package com.wy.shopping.service.impl;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wy.common.utils.PageUtils;
import com.wy.common.utils.Query;

import com.wy.shopping.dao.OrderInfoDao;
import com.wy.shopping.entity.OrderInfoEntity;
import com.wy.shopping.service.OrderInfoService;


@Service("orderInfoService")
public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoDao, OrderInfoEntity> implements OrderInfoService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        QueryWrapper<OrderInfoEntity> wrapper = new QueryWrapper<>();
        String userId = (String) params.get("userId");
        String key = (String) params.get("key");
        wrapper.eq("user_id",userId);
        if (StringUtils.isNotEmpty(key)) {
            wrapper.like("goods_name",key);
        }
        IPage<OrderInfoEntity> page = this.page(
                new Query<OrderInfoEntity>().getPage(params),
                wrapper
        );

        return new PageUtils(page);
    }

}